import os
from pymatgen.io.vaspio import Poscar
from vasp.io import TemporaryDirectory

class Vesta:
    def __init__(self, structure):
        self.structure = structure
        self.vesta = '~/VESTA-x86_64/VESTA'

    def show(self):
        tmp = TemporaryDirectory()
        path = tmp.path + 'POSCAR'

        poscar = Poscar(self.structure)
        poscar.write_file(path)
        if os.system(self.vesta + ' ' + path) != 0:
            raise Exception('Couldn\'t launch VESTA.')

        tmp.close()
